/*
 * Copyright (C) 2004, Velocityme Partnership
 * ChangeStateActionForm.java
 *
 * Created on 05 September 2004, 05:21
 */

package com.velocityme.www.actionforms;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
import org.apache.struts.upload.FormFile;
import org.apache.struts.upload.MultipartRequestHandler;

/**
 *
 * @author  Robert
 */
public class ChangeStateActionForm extends TimeActionForm {
    
    private long m_transitionId;
    private boolean m_assignTime;
    private FormFile m_file;
        
    /**
     * Check to make sure the client hasn't exceeded the maximum allowed upload size inside of this
     * validate method.
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        // has the maximum length been exceeded?
        Boolean maxLengthExceeded = (Boolean)request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
        if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {
            ActionErrors errors = new ActionErrors();
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.file.maxLengthExceeded"));
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.file.maxLengthExplanation"));
            return errors;
        }
        return super.validate(mapping, request);
    }
    
    public long getTransitionId() { return m_transitionId; }
    
    public void setTransitionId(long transitionId) { m_transitionId = transitionId; }
    
    public boolean isAssignTime() { return m_assignTime; }
    
    public void setAssignTime(boolean assignTime) { m_assignTime = assignTime; }
    
    public FormFile getFile() { return m_file; }
    
    public void setFile(FormFile file) { m_file = file; }
    
}
